if (process.env.NODE_ENV !== 'production') {
  require('./home.html')
}
import 'bootstrap/dist/css/bootstrap.min.css'
import 'bootstrap/dist/js/bootstrap.min'
import './home.less'
import '../../vendors/animate.css'

import './translate'

var windowH = $(window).height()
var introductionSt = $('#introduction').offset().top - windowH
var milestoneSt = $('#milestone').offset().top - windowH
var merchantsSt = $('#merchants').offset().top - windowH
var downloadSt = $('#download').offset().top - windowH


var leaveTop = false
var introductionFlag = false
var milestoneFlag = false
var merchantsFlag = false
var downloadFlag = false

$('#apply').on('click', function () {
  alert('立即申请')
})

$(window).scroll(function () {
  var t = document.documentElement.scrollTop||document.body.scrollTop
  // 顶部动效
  if (!leaveTop && t > 50) {
    leaveTop = true
    $('#topNavbar').addClass('navbar-active')
  } else if (leaveTop && t <= 50) {
    leaveTop = false
    $('#topNavbar').removeClass('navbar-active')
  }

  // 产品介绍
  if (!introductionFlag && t >= introductionSt) {
    introductionFlag = true
    $('#introductionAni0').addClass('animated flipInX')
    $('#introductionAni1').addClass('animated zoomIn')
    $('#introductionAni2').addClass('animated delay-1s zoomIn')
    $('#introductionAni3').addClass('animated delay-2s zoomIn')
  }

  // 产品规划
  if (!milestoneFlag && t >= milestoneSt) {
    milestoneFlag = true
    $('#milestoneAni0').addClass('animated flipInX')
    $('#milestoneAni1').addClass('animated delay-1s fadeInRight')
    $('#milestoneAni2').addClass('animated delay-1s fadeInLeft')
    $('#milestoneAni3').addClass('animated delay-2s fadeInRight')
    $('#milestoneAni4').addClass('animated delay-2s fadeInLeft')
    $('#milestoneAni5').addClass('animated delay-3s fadeInRight')
    $('#milestoneAni6').addClass('animated delay-3s fadeInLeft')
    $('#milestoneAni7').addClass('animated delay-4s fadeInRight')
    $('#milestoneAni8').addClass('animated delay-4s fadeInLeft')
    setTimeout(function () {
      $('#milestoneAni1').removeClass('fadeInRight')
      $('#milestoneAni1').addClass('milestoneAni infinite slow')
    }, 2000)
    setTimeout(function () {
      $('#milestoneAni4').removeClass('fadeInRight')
      $('#milestoneAni4').addClass('milestoneAni infinite slow')
    }, 3000)
    setTimeout(function () {
      $('#milestoneAni5').removeClass('fadeInRight')
      $('#milestoneAni5').addClass('milestoneAni infinite slow')
    }, 4000)
    setTimeout(function () {
      $('#milestoneAni8').removeClass('fadeInRight')
      $('#milestoneAni8').addClass('milestoneAni infinite slow')
    }, 4000)
  }

  // 成为商家
  if (!merchantsFlag && t >= merchantsSt) {
    merchantsFlag = true
    $('#merchantsAni0').addClass('animated flipInX')
    $('#merchantsAni1').addClass('animated fadeInUp')
    $('#merchantsAni2').addClass('animated fadeInUp delay-1s')
    $('#merchantsAni3').addClass('animated fadeInUp delay-2s')
    $('#apply').addClass('animated fadeInUp delay-3s')
    setTimeout(function () {
      $('#merchantsAni1').removeClass('fadeInUp')
      $('#merchantsAni1').addClass('merchantsAni infinite slow')
    }, 1000)
    setTimeout(function () {
      $('#merchantsAni2').removeClass('fadeInUp')
      $('#merchantsAni2').addClass('merchantsAni infinite slow')
    }, 2000)
    setTimeout(function () {
      $('#merchantsAni3').removeClass('fadeInUp')
      $('#merchantsAni3').addClass('merchantsAni infinite slow')
    }, 3000)
  }

  // 下载
  if (!downloadFlag && t >= downloadSt) {
    downloadFlag = true
    $('#downloadLeft').addClass('animated fadeInLeft delay-1s')
    $('#downloadRight').addClass('animated fadeInRight delay-1s')
    $('#downloadPicture').addClass('animated downloadAni infinite slower delay-2s')
  }
})